package com.faithbj.common_service.dao.impl;

import com.faithbj.common.dao.impl.BaseDaoImpl;
import com.faithbj.common.model.compare.IBAOfficalData;
import com.faithbj.common_service.dao.IBAOfficalDataDao;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils;

import java.util.List;

@Repository("IBAOfficalDataDao")
public class IBAOfficalDataDaoImpl extends BaseDaoImpl<IBAOfficalData, String> 
implements IBAOfficalDataDao{
    @Override
    public List<IBAOfficalData> queryListForUpdate(String batchNum, String departmentNum, String mainApplicantCardId) {
        Criteria criteria = this.getSession().createCriteria(IBAOfficalData.class);
        if(StringUtils.hasLength(batchNum)){
            criteria.add(Restrictions.eq("batchNum", batchNum));
        }
        if(StringUtils.hasLength(departmentNum)){
            criteria.add(Restrictions.eq("departmentNum", departmentNum));
        }
        if(StringUtils.hasLength(mainApplicantCardId)){
            criteria.add(Restrictions.eq("mainApplicantCardNum", mainApplicantCardId));
        }
        return criteria.list();
    }
}
